@extends('home.parent')
@section('title','关键词视频评论列表')
@section('head_js')
@endsection
@section('head_css')
<link rel="stylesheet" href="{{ asset('/css/dataTables.bootstrap.css') }}">
<link rel="stylesheet" href="{{ asset('/css/toggleButtonsMain.css') }}">
<link rel="stylesheet" href="{{ asset('/css/datepicker3.css') }}">
@endsection
@section('content')
  <div class="content-wrapper">
    <section class="content-header">
      <h1>
        关键词视频评论列表
        <small></small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="{{URL('admin')}}"><i class="fa fa-dashboard"></i> 首页</a></li>
        <li class="active">关键词视频评论列表</li>
      </ol>
    </section>
    <section class="content">
      <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <div class="form-inline pull-right">
                <fieldset>
                  <div class="input-group input-group-sm">
                    <span class="input-group-addon"><strong>评论</strong></span>
                    <input type="text" class="form-control" id="search_content">
                  </div>
                  <div class="input-group input-group-sm">
                    <span class="input-group-addon"><strong>更新时间</strong></span>
                    <input type="text" class="form-control" id="start_date" style="width:90px;" autocomplete="off">
					<span class="form-control" style="width:5px;border-right:none;border:none;padding:5px 0;">-</span>
					<input type="text" class="form-control" id="end_date" style="width:90px;" autocomplete="off">
                  </div>
                  <div class="input-group input-group-sm">
                    <span class="input-group-addon"><strong>是否显示</strong></span>
                    <select class="form-control" id="status">
						<option value="99">全部</option>
						<option value="0">不显示</option>
						<option value="1">显示</option>
					</select>
                  </div>
                  <div class="input-group input-group-sm">
                    <div class="input-group-btn">
                      <button type="button"  class="btn btn-primary" onclick="searchData()"><i class="fa fa-search"></i></button>
                    </div>
                  </div>
                </fieldset>
              </div>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <table id="data_list" class="table table-bordered table-striped">
                <thead>
                  <tr>
                    <th>内容</th>
                    <th>用户头像</th>
                    <th>用户昵称</th>
                    <th>用户账号</th>
                    <th>用户签名</th>
                    <th>联系方式</th>
                    <th>来源视频</th>
                    <th width="70px">所属行业</th>
                    <th >视频标题</th>
                    <th width="80px">评论时间</th>
                    <th width="80px">更新时间</th>
                    <th width="60px">是否显示</th>
                  </tr>
                </thead>
                <tbody>
                </tbody>
                <tfoot>
                  <tr>
                    <th>内容</th>
                    <th>用户头像</th>
                    <th>用户昵称</th>
                    <th>用户账号</th>
                    <th>用户签名</th>
                    <th>联系方式</th>
                    <th>来源视频</th>
                    <th>所属行业</th>
                    <th>视频标题</th>
                    <th>评论时间</th>
                    <th>更新时间</th>
                    <th>是否显示</th>
                  </tr>
                </tfoot>
              </table>
            </div>
          </div>
        </div>
      </div>
    </section>
  </div>
@endsection
@section('foot_js')
<script src="{{ asset('/js/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('/js/dataTables.bootstrap.min.js') }}"></script>
<script src="{{ asset('/js/jquery.slimscroll.min.js') }}"></script>
<script src="{{ asset('/js/fastclick.js') }}"></script>
<script src="{{ asset('/js/tools.js') }}"></script>
<script src="{{ asset('/js/bootstrap-datepicker.js') }}"></script>
<script>
$(document).ready(function(){
	$('#start_date').datepicker({
		startDate: "",
		todayHighlight: true,
		language: "zh-CN",
		autoclose: true,//选中之后自动隐藏日期选择框
		format: "yyyy-mm-dd"//日期格式，详见 http://bootstrap-datepicker.readthedocs.org/en/release/options.html#format
	});
	$('#end_date').datepicker({
		startDate: "",
		todayHighlight: true,
		language: "zh-CN",
		autoclose: true,//选中之后自动隐藏日期选择框
		format: "yyyy-mm-dd"//日期格式，详见 http://bootstrap-datepicker.readthedocs.org/en/release/options.html#format
	});
})
var list_ajax;
$(function () {
  //提示信息
  var lang = puppet.langShow();
  //初始化表格
  list_ajax = $("#data_list").dataTable({
    language: lang, //提示信息
    autoWidth: false, //禁用自动调整列宽
    stripeClasses: ["odd", "even"], //为奇偶行加上样式，兼容不支持CSS伪类的场合
    processing: true, //隐藏加载提示,自行处理;
    serverSide: true, //启用服务器端分页
    searching: false, //禁用原生搜索
    //"sSearch": "搜索:",
    orderMulti: false, //启用多列排序
    order: [[0, 'desc']], //取消默认排序查询,否则复选框一列会出现小箭头
    renderer: "bootstrap", //渲染样式：Bootstrap和jquery-ui
    pagingType: "simple_numbers", //分页样式：simple,simple_numbers,full,full_numbers
    aLengthMenu : [10, 20, 50, 100], //更改显示记录数选项
    iDisplayLength:10,
    columnDefs: [
      {
        "targets": [1,2,3,4,5,6,7,8,9,10,11], //列的样式名
        "orderable": false    //包含上样式名‘nosort’的禁止排序
      },
    ],
    ajax: function (data, callback, settings) {
      //封装请求参数
      var param = {};
      param.limit = data.length; //页面显示记录条数，在页面显示每页显示多少项的时候
      param.start = data.start; //开始的记录序号
      param.page = (data.start / data.length) + 1; //当前页码
      param.order = data.order;
      param.content = $.trim($("#search_content").val());
      param.start_date = $.trim($("#start_date").val());
      param.end_date = $.trim($("#end_date").val());
      param.status = $.trim($("#status").val());
      $.ajax({
        type: "POST",
        url: "{{ URL('admin/keyword/video/comment/list/ajax') }}",
        cache: false, //禁用缓存
        data: param, //传入组装的参数
        dataType: "json",
        success: function (result) {
          var returnData = {};
          returnData.draw = data.draw; //这里直接自行返回了draw计数器,应该由后台返回
          returnData.recordsTotal = result.total; //返回数据全部记录
          returnData.recordsFiltered = result.total; //后台不实现过滤功能，每次查询均视作全部结果
          returnData.data = result.data; //返回的数据列表
          callback(returnData);
        }
      });
    },
    //列表表头字段
    columns: [
      {"data": "content"},
      {"data": "userImg"},
      {"data": "nickname"},
      {"data": "user_id"},
      {"data": "signature"},
      {"data": "tells"},
      {"data": "video_url"},
      {"data": "keyword"},
      {"data": "title"},
      {"data": "create_time"},
      {"data": "update_time"},
      {"data": "status"},
    ],
  }).api();
});
function searchData(){
  $("#data_list").dataTable().fnDraw(false);
    layer.msg('操作成功',{icon:1});
}
function actionList(kid,status){
    var result;
    switch(status){
        case 0:
            result = layer.confirm('是否确认关闭', {
                btn: ['确认关闭', '再考虑一下'] //按钮
            }, function () {
                layer.msg('操作成功',{icon:1});
                xiugai(kid,status);
                list_ajax.ajax.reload(null,false);
            },function () {
                list_ajax.ajax.reload(null,false);
            });
            break;
        case 1:
            result = layer.confirm('是否确认开启', {
                btn: ['确认开启', '再考虑一下'] //按钮
            }, function () {
                layer.msg('操作成功',{icon:1});
                xiugai(kid,status);
                list_ajax.ajax.reload(null,false);
            },function () {
                list_ajax.ajax.reload(null,false);
            });
            break;
        case -1:
            result = layer.confirm('是否确认删除', {
                btn: ['确认删除', '再考虑一下'] //按钮
            }, function () {
                layer.msg('操作成功',{icon:1});
                xiugai(kid,status);
            });
            break;
        default:
            result = layer.confirm('是否确认删除', {
                btn: ['确认删除', '再考虑一下'] //按钮
            }, function () {
                xiugai(kid,status);
            });
            break;
    }
}
function xiugai(kid,status) {
    var url = "{{ URL('keyword/video/status') }}";
    var data = {kid:kid,status:status};
    var result = puppet.myajax('post',url,data,false);
    if(result.code == 1){
        layer.msg("操作失败",{icon:2});
        return false;
    }else{
        layer.msg("操作成功",{icon:1});
    }
}
function savTells(obj,kid){
	var text=$(obj).prev().prev('textarea').val();
	var url = "{{ URL('keyword/video/save') }}";
	var data = {kid:kid,text:text};
	var result = puppet.myajax('post',url,data,false);
	if(result.code == 1){
        layer.msg("修改失败",{icon:5});
		return false;
	}else{
        layer.msg("修改成功",{icon:6});
        list_ajax.ajax.reload(null,false);
	}
}
</script>
@endsection